package com.numbfish.ch_05.future_callable_1.src.test ;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.numbfish.ch_05.future_callable_1.src.mycallable.MyCallable;

public class Run {

	public static void main(String[] args) throws InterruptedException {
		try {
			MyCallable callable = new MyCallable(100);

			ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3, 5L,
					TimeUnit.SECONDS, new LinkedBlockingDeque());
			Future<String> future = executor.submit(callable);
			System.out.println("main A " + System.currentTimeMillis());
			System.out.println(future.get());
			System.out.println("main B " + System.currentTimeMillis());
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}
}